<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('报废原因')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-role-add">

        <div class="form-group">
            <label class="col-sm-3 control-label ">partStatus：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="partStatus" id="partStatus" required >
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">description：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="description" id="description" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">demandFlag：</label>
            <div class="col-sm-8">
                <select name="demandFlag" th:with="type=${@dict.getType('sys_yes_no')}">
                    <option value="">所有</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">onhandFlag：</label>
            <div class="col-sm-8">
                <select name="onhandFlag" th:with="type=${@dict.getType('sys_yes_no')}">
                    <option value="">所有</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">supplyFlag：</label>
            <div class="col-sm-8">
                <select name="supplyFlag" th:with="type=${@dict.getType('sys_yes_no')}">
                    <option value="">所有</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">defaultStatus：</label>
            <div class="col-sm-8">
                <label class="toggle-switch switch-solid">
                    <input type="checkbox" id="defaultStatus" checked>
                    <span></span>
                </label>
            </div>
        </div>

    </form>

</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">
    function submitHandler() {
        add();
    }

    function add() {
        var partStatus = $("input[name='partStatus']").val();
        var description = $("input[name='description']").val();
        var demandFlag = $("select[name='demandFlag']").val();
        var onhandFlag = $("select[name='onhandFlag']").val();
        var supplyFlag = $("select[name='supplyFlag']").val();
        var defaultStatus = $("input[id='defaultStatus']").is(':checked') == true ? 'TRUE': 'FALSE';
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "inventoryStatuses/add",
            data: {
                "partStatus":partStatus,
                "description":description,
                "demandFlag":demandFlag,
                "onhandFlag":onhandFlag,
                "supplyFlag":supplyFlag,
                "defaultStatus":defaultStatus,
            },

            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>
